<?php
/**
 * @文件功能名称  : 邮箱设置
 * @Author      : yaoGrace
 * @Date        : 2021/12/11 23:22
 */
 namespace phpGrace\models;
 class email extends \graceModel{
     public $tableName = "email";
     public $tableKey ='id';

     /**
      * 获取该表的所有数据，通过ID 升序排序
      * @return array
      */
    public function getallList(){
        //调用graceModel 里面的 获取表数据方法
        $data = $this->m->page(15)->fetchAll();
        $data['count'] = $this->m->count();
        return  $data;
    }

     /**
      * 添加数据，返回添加成功的id
      * @param $data
      * @return id
      */
     public function add($data)
     {
        return $this->m->add($data);
     }

     //编辑页面初始化数据
     public function editGetListByID($ID)
     {
          return $this->m->where($this->tableKey. '= ? ',array($ID))->fetch();
     }

     /**
      * 更新
      * @param $id
      * @param $data
      */
     public function update($id,$data)
     {
        return $this->m->where($this->tableKey." = ?",array($id))->update($data);
     }

     public function fetchWhere($id){
         return $this->m->where('id = ? ',array($id))->fetch();
     }

     public function dels($id)
     {
         return $this->m->where("id = ? ",array($id))->delete();
     }
 }